<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="text/javascript">

        const users = {
            Alex: {
                email: 'alex@alex.com',
                skills: ['HTML', 'CSS', 'JavaScript'],
                age: 20,
                isLoggedIn: false,
                points: 30
            },
            Asab: {
                email: 'asab@asab.com',
                skills: ['HTML', 'CSS', 'JavaScript', 'Redux', 'MongoDB', 'Express', 'React', 'Node'],
                age: 25,
                isLoggedIn: false,
                points: 50
            },
            Brook: {
                email: 'daniel@daniel.com',
                skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux'],
                age: 30,
                isLoggedIn: true,
                points: 50
            },
            Daniel: {
                email: 'daniel@alex.com',
                skills: ['HTML', 'CSS', 'JavaScript', 'Python'],
                age: 20,
                isLoggedIn: false,
                points: 40
            },
            John: {
                email: 'john@john.com',
                skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux', 'Node.js'],
                age: 20,
                isLoggedIn: true,
                points: 50
            },
            Thomas: {
                email: 'thomas@thomas.com',
                skills: ['HTML', 'CSS', 'JavaScript', 'React'],
                age: 20,
                isLoggedIn: false,
                points: 40
            },
            Paul: {
                email: 'paul@paul.com',
                skills: ['HTML', 'CSS', 'JavaScript', 'MongoDB', 'Express', 'React', 'Node'],
                age: 20,
                isLoggedIn: false,
                points: 40
            }
        }

        //统计在线人数 
        const keysArr = Object.keys(users)  //字符串.
        var count = 0
        keysArr.forEach(
            function (item) {
                users[item].isLoggedIn == true ? count++ : count
            }
        )
       



        // 2.统计分数大于50的人数
        var scores = 0  //一开始0人
        keysArr.forEach(
            function(item) {
                users[item].points >= 50 ? scores++ : scores
            }
        )
        console.log('分数大于50   '+scores);


        // 3.查找会MongoDB的人，并打印其名字
        //数组 incldues()
        const personArr = []
        keysArr.forEach(
            function(item){
                users[item].skills.includes('MongoDB') ? personArr.push(item) : personArr
            }
        )
        console.log('会MongoDB的人 : ' + personArr);


        // 4.查找同时会：MongoDB， Express，React，和Node 的人，并打印其名字
        const nskill = ['MongoDB','Express','React','Node'];  
        //keyArr:键
        keysArr.forEach(
            function (item){
                //console.log(item+'掌握的技能: '+users[item].skills);
                // const isMaster = nskill.every(
                //     function (it){
                //         return users[item].skills.includes(it);
                //     }
                // )

                //1. const isMatser = nskill.every(it => users[item].skills.includes(it))
                
                //2.const isMaster = users[item].skills.includes('MongoDB','Express','React','Node')
                console.log(isMaster);

                if(isMaster){
                    console.log(item+'掌握了该四门技能');
                }

            }
        )

    </script>
</body>

</html>